import { _decorator, Component, Node, EventTouch } from 'cc';
const { ccclass, property } = _decorator;

import { GameRoot } from './GameRoot';
import { TaKuSDK } from './TaKuSDK';

@ccclass('Result')
export class Result extends Component {
    @property(Node)
    private nextBtn: Node = null;

    @property(Node)
    private ADBtn: Node = null;
    
    
    start(){
        this.nextBtn.on(Node.EventType.TOUCH_START, this.onNextBtnClick, this);
        this.ADBtn.on(Node.EventType.TOUCH_START, this.onADBtnClick, this);
    }

    onNextBtnClick(event: EventTouch, customEventData: string){
        console.log("onNextBtnClick");
        this.node.parent.getComponent(GameRoot).onCloseLayer();
    }

    onADBtnClick(event: EventTouch, customEventData: string){
        console.log("onADBtnClick");
        try{
            // 显示激励视频广告
            TaKuSDK.getInstance().showRewardedVideoAd();
        }catch(e){
            console.log("showRewardedVideoAd error", e);
        }
    }
}


